package com.cwt_taxi_xa;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.cwt_taxi_xa.constants.Constants;
import com.cwt_taxi_xa.constants.SPConstants;
import com.cwt_taxi_xa.data.DataUtil;
import com.cwt_taxi_xa.db.bll.LocalInfoBiz;
import com.cwt_taxi_xa.model.LocalInfo;
import com.cwt_taxi_xa.model.RecorderInfo;
import com.cwt_taxi_xa.protocol.DeviceBiz;
import com.cwt_taxi_xa.record.RecorderBiz;
import com.cwt_taxi_xa.util.AppLog;
import com.cwt_taxi_xa.util.DateUtil;
import com.cwt_taxi_xa.util.DecimalUtil;
import com.cwt_taxi_xa.util.ExceptionUtil;
import com.cwt_taxi_xa.util.FileOper;
import com.cwt_taxi_xa.util.SPUtils;
import com.cwt_taxi_xa.util.StringUtil;
import com.cwt_taxi_xa.util.ToastUtils;
import com.cwt_taxi_xa.util.Tools;
import com.cwt_taxi_xa.widget.timepicker.ScreenInfo;
import com.cwt_taxi_xa.widget.timepicker.WheelMain;

public class DownloadDataSelection extends CWTBaseActivity implements OnClickListener {

	public static Handler handler;
	public static boolean isExit = false;
	private boolean isUsbExit = false;
	// private String copyRootPath = DeviceBiz.getSdcardPath();
	private String copyRootPath = "/mnt/usbhost/Storage00";// 出货使用U盘存储介质
	// private String copyRootPath = Constants.SDPath;//出货使用U盘存储介质
	// private String copyRootPath = Constants.RAM_PATH;

	// private String copyPath = copyRootPath + "/DHKJ_LOCAL_DATA/";
	private String copyFilePath = "";
	private String fileName = "";
	private TextView tv_start_time, tv_end_time, tv_count;
	private Spinner sp_type, sp_photo_reason, sp_record_reason, sp_post_status, sp_channel_id, sp_download_type;
	private LinearLayout ll_photo_reason, ll_record_reason, ll_post_status, ll_channel_id, ll_start_time, ll_end_time, ll_download_type;
	private CheckBox cb_etime, cb_stime;

	/**
	 * 0:营运数据 1:上班签到数据 2:下班签退数据 3:GPS位置数据 4:服务监督卡 5:录音文件 6:照片文件
	 */
	private int data_type = 0;

	public static final int TYPE_BUSINESS = 0;
	public static final int TYPE_CHECKIN = 1;
	public static final int TYPE_CHECKOUT = 2;
	public static final int TYPE_GPS = 3;
	public static final int TYPE_PHOTO = 4;
	public static final int TYPE_RECORDING = 5;
	public static final int TYPE_SERVICE_CARD = 6;
	public static final int TYPE_DEVICE_PARAMS = 7;

	private int postStatus;
	private int photoReason;
	private int recordReason;
	private int channelId;
	private int downloadType;
	private String sTime;
	private String eTime;

	private LocalInfoBiz localInfoBiz;
	private RecorderBiz recorderBiz;

	private ArrayList<LocalInfo> localInfos = null;
	private ArrayList<RecorderInfo> recorderInfos = null;

	private Button btn_check, btn_down_load, btn_record;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.download_data_selection);

		handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				super.handleMessage(msg);
			}
		};
		isExit = true;
		setupViews();
		addListener();
		initData();
	}

	private void initData() {
		// TODO Auto-generated method stub
		changeTime();
		checkUD();
	}

	private void checkUD() {
		// 启动U盘检测
		try {
			long sdsize = 0;
			for (int i = 0; i < 10; i++) {
				copyRootPath = copyRootPath.substring(0, copyRootPath.length() - 1) + i;
				sdsize = FileOper.getSDAllSize(copyRootPath);
				if (sdsize > 1) {
					break;
				}
			}
			if (sdsize < 20) {
				isUsbExit = false;
			} else {
				isUsbExit = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void changeTime() {
		// TODO Auto-generated method stub
		calendar = Calendar.getInstance();
		calendarST = Calendar.getInstance();
		calendarET = Calendar.getInstance();
		year = calendar.get(Calendar.YEAR);
		month = calendar.get(Calendar.MONTH);
		day = calendar.get(Calendar.DAY_OF_MONTH);
		h = calendar.get(Calendar.HOUR_OF_DAY);
		m = calendar.get(Calendar.MINUTE);

		calendarST.set(year, month, day - 1, h, m - 1);
		Date date = calendarST.getTime();
		tv_start_time.setText(DateUtil.df13.format(date));

		calendarET.set(year, month, day, h, m - 1);
		date = calendarET.getTime();
		tv_end_time.setText(DateUtil.df13.format(date));
	}

	private void changeType(int type) {
		// TODO Auto-generated method stub
		data_type = type;

		ll_photo_reason.setVisibility(View.GONE);
		ll_record_reason.setVisibility(View.GONE);
		ll_channel_id.setVisibility(View.GONE);
		ll_end_time.setVisibility(View.GONE);
		ll_start_time.setVisibility(View.GONE);
		ll_post_status.setVisibility(View.GONE);
		ll_download_type.setVisibility(View.GONE);
		btn_record.setVisibility(View.GONE);

		switch (data_type) {
			case TYPE_BUSINESS:
				ll_post_status.setVisibility(View.VISIBLE);
				ll_end_time.setVisibility(View.VISIBLE);
				ll_start_time.setVisibility(View.VISIBLE);
				ll_download_type.setVisibility(View.VISIBLE);
				cb_stime.setChecked(false);
				cb_etime.setChecked(false);
				break;
			case TYPE_CHECKIN:
				ll_post_status.setVisibility(View.VISIBLE);
				ll_end_time.setVisibility(View.VISIBLE);
				ll_start_time.setVisibility(View.VISIBLE);
				ll_download_type.setVisibility(View.VISIBLE);
				cb_stime.setChecked(false);
				cb_etime.setChecked(false);
				break;
			case TYPE_CHECKOUT:
				ll_post_status.setVisibility(View.VISIBLE);
				ll_end_time.setVisibility(View.VISIBLE);
				ll_start_time.setVisibility(View.VISIBLE);
				ll_download_type.setVisibility(View.VISIBLE);
				cb_stime.setChecked(false);
				cb_etime.setChecked(false);
				break;
			case TYPE_GPS:
				ll_post_status.setVisibility(View.VISIBLE);
				ll_end_time.setVisibility(View.VISIBLE);
				ll_start_time.setVisibility(View.VISIBLE);
				ll_download_type.setVisibility(View.VISIBLE);
				cb_stime.setChecked(false);
				cb_etime.setChecked(false);
				break;
			case TYPE_SERVICE_CARD:
			case TYPE_DEVICE_PARAMS:
				break;
			case TYPE_RECORDING:
				ll_end_time.setVisibility(View.VISIBLE);
				ll_start_time.setVisibility(View.VISIBLE);
				ll_record_reason.setVisibility(View.VISIBLE);
//			btn_record.setVisibility(View.VISIBLE);
				cb_stime.setChecked(false);
				cb_etime.setChecked(false);
				break;
			case TYPE_PHOTO:
				ll_photo_reason.setVisibility(View.VISIBLE);
				ll_channel_id.setVisibility(View.VISIBLE);
				ll_end_time.setVisibility(View.VISIBLE);
				ll_start_time.setVisibility(View.VISIBLE);
				cb_stime.setChecked(false);
				cb_etime.setChecked(false);
				break;

			default:
				break;
		}
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		isExit = false;
	}

	private void setupViews() {
		// TODO Auto-generated method stub
		tv_count = (TextView) findViewById(R.id.tv_count);
		btn_check = (Button) findViewById(R.id.btn_check);
		btn_down_load = (Button) findViewById(R.id.btn_down_load);
		btn_record = (Button) findViewById(R.id.btn_record);

		tv_start_time = (TextView) findViewById(R.id.tv_start_time);
		tv_end_time = (TextView) findViewById(R.id.tv_end_time);
		cb_etime = (CheckBox) findViewById(R.id.cb_etime);
		cb_stime = (CheckBox) findViewById(R.id.cb_stime);

		sp_type = (Spinner) findViewById(R.id.sp_type);
		sp_photo_reason = (Spinner) findViewById(R.id.sp_photo_reason);
		sp_record_reason = (Spinner) findViewById(R.id.sp_record_reason);
		sp_post_status = (Spinner) findViewById(R.id.sp_post_status);
		sp_channel_id = (Spinner) findViewById(R.id.sp_channel_id);
		sp_download_type = (Spinner) findViewById(R.id.sp_download_type);

		ll_photo_reason = (LinearLayout) findViewById(R.id.ll_photo_reason);
		ll_record_reason = (LinearLayout) findViewById(R.id.ll_record_reason);
		ll_post_status = (LinearLayout) findViewById(R.id.ll_post_status);
		ll_channel_id = (LinearLayout) findViewById(R.id.ll_channel_id);
		ll_start_time = (LinearLayout) findViewById(R.id.ll_start_time);
		ll_end_time = (LinearLayout) findViewById(R.id.ll_end_time);
		ll_download_type = (LinearLayout) findViewById(R.id.ll_download_type);

		data_type = getIntent().getIntExtra("type", TYPE_BUSINESS);
		sp_type.setSelection(data_type);
	}

	private void addListener() {
		// TODO Auto-generated method stub
		tv_start_time.setOnClickListener(this);
		tv_end_time.setOnClickListener(this);
		btn_check.setOnClickListener(this);
		btn_down_load.setOnClickListener(this);
		btn_record.setOnClickListener(this);

		sp_type.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				changeType(position);
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		sp_post_status.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				postStatus = position;
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		sp_photo_reason.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				photoReason = position;
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		sp_record_reason.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				recordReason = position;
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		sp_channel_id.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				channelId = position;
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
		sp_download_type.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
				// TODO Auto-generated method stub
				downloadType = position;
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub

			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
			case R.id.tv_start_time:
				choiceTime(tv_start_time);
				break;
			case R.id.tv_end_time:
				choiceTime(tv_end_time);
				break;
			case R.id.btn_check:
				doCheck();
				break;
			case R.id.btn_down_load:
				doDownLoad();
				break;
			case R.id.btn_record:
				startActivity(new Intent(DownloadDataSelection.this, RecordList.class));
				break;
		}
	}

	private void doDownLoad() {
		// TODO Auto-generated method stub
		checkUD();
		if (!isUsbExit) {
			ToastUtils.showToastForCustom("请先插入U盘！");
			return;
		}
		switch (data_type) {
			case TYPE_BUSINESS:
				copyFilePath = copyRootPath + "/SXDH_DATA/" + "business_data/";
				fileName = "business_data.txt";
				downLoadBusinessData();
				break;
			case TYPE_CHECKIN:
				copyFilePath = copyRootPath + "/SXDH_DATA/" + "checkin_data/";
				fileName = "check_in_data.txt";
				downLoadCheckinData();
				break;
			case TYPE_CHECKOUT:
				copyFilePath = copyRootPath + "/SXDH_DATA/" + "checkout_data/";
				fileName = "check_out_data.txt";
				downLoadCheckoutData();
				break;
			case TYPE_GPS:
				copyFilePath = copyRootPath + "/SXDH_DATA/" + "gps_data/";
				fileName = "gps_data.txt";
				downLoadGpsData();
				break;
			case TYPE_PHOTO:
				/*
				 * copyFilePath = copyPath + "photo_data/"; fileName =
				 * "photo_data.txt"; downLoadPhotoData();
				 */
				ToastUtils.showToastForCustom("暂不支持照片！");
				break;
			case TYPE_RECORDING:
				copyFilePath = copyRootPath + "/SXDH_DATA/" + "recording_data/";
				fileName = "recording_data.txt";
				downLoadRecordData();
				break;
			case TYPE_SERVICE_CARD:
				/*
				 * copyFilePath = copyPath + "driver_data/"; fileName =
				 * "driver_data.txt"; downLoadServiceCardData();
				 */
				ToastUtils.showToastForCustom("暂不支持司机信息！");
				break;
			case TYPE_DEVICE_PARAMS:
				copyFilePath = copyRootPath + "/SXDH_DATA/" + "device_params_data/";
				fileName = "device_params_data.txt";
				downDeviceParamsData();
				break;

			default:
				break;
		}
	}

	private void downDeviceParamsData() {
		// TODO Auto-generated method stub
		writeDatatoFile();
	}

	private void downLoadRecordData() {
		// TODO Auto-generated method stub
		if (recorderInfos != null && recorderInfos.size() != 0) {
			writeDatatoFile();
		} else {
			ToastUtils.showToastForCustom("数据不存在！");
		}
	}

	private void downLoadGpsData() {
		// TODO Auto-generated method stub
		if (localInfos != null && localInfos.size() != 0) {
			writeDatatoFile();
		} else {
			ToastUtils.showToastForCustom("数据不存在！");
		}
	}

	private void downLoadCheckoutData() {
		// TODO Auto-generated method stub
		if (localInfos != null && localInfos.size() != 0) {
			writeDatatoFile();
		} else {
			ToastUtils.showToastForCustom("数据不存在！");
		}
	}

	private void downLoadCheckinData() {
		// TODO Auto-generated method stub
		if (localInfos != null && localInfos.size() != 0) {
			writeDatatoFile();
		} else {
			ToastUtils.showToastForCustom("数据不存在！");
		}
	}

	private void downLoadBusinessData() {
		// TODO Auto-generated method stub
		if (localInfos != null && localInfos.size() != 0) {
			writeDatatoFile();
		} else {
			ToastUtils.showToastForCustom("数据不存在！");
		}
	}

	/**
	 * 写数据
	 *
	 * @return
	 * **/
	File file;

	private void writeDatatoFile() {

		// 查看SD卡剩余内存情况
		try {
			long sdsize = FileOper.getSDAllSize(copyRootPath);
			if (sdsize < 20) {
				ToastUtils.showToastForCustom("存储空间不足！");
				return;
			}
		} catch (Exception e) {
			e.printStackTrace();
			AppLog.e(ExceptionUtil.getInfo(e), e);
		}

		// 检查文件路径是否存在
		File filePath = new File(copyFilePath);
		if (!filePath.exists()) {
			boolean result = filePath.mkdirs();
			AppLog.i("本地数据；path:" + copyFilePath + "; result:" + result);
		}

		file = new File(copyFilePath, fileName);

		try {
			file.deleteOnExit();
			boolean result = file.createNewFile();
			AppLog.i("本地数据；file:" + file.getAbsolutePath() + "; result:" + result);

			FileWriter filerWriter = new FileWriter(file, false);// 后面这个参数代表是不是要接上文件中原来的数据，不进行覆盖
			BufferedWriter bufWriter = new BufferedWriter(filerWriter);
			writeData(filerWriter, bufWriter);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			AppLog.e(ExceptionUtil.getInfo(e), e);
			e.printStackTrace();
		}
	}

	private void writeData(FileWriter filerWriter, BufferedWriter bufWriter) {
		// TODO Auto-generated method stub
		try {
			switch (data_type) {
				case TYPE_BUSINESS:
				case TYPE_CHECKIN:
				case TYPE_CHECKOUT:
				case TYPE_GPS:
					for (int i = 0; i < localInfos.size(); i++) {
						if (downloadType == 0) {
							bufWriter.write("\n------------------------- 第" + (i + 1) + "条 ------------------------------\n\n");
							String data = getClearShowData(data_type, localInfos.get(i));
							bufWriter.write(data + "\n");
						} else {
							bufWriter.write(localInfos.get(i).getData() + "\n\n");
						}
					}
					break;
				/*
				 * case TYPE_PHOTO: for(int i =0;i<photoInfos.size();i++){ PhotoInfo
				 * photoInfo = photoInfos.get(i);
				 *
				 * String oldPath =
				 * Constants.CAMERA_PATH+"/"+photoInfo.getTime()+".jpg"; File
				 * photoFile = new File(oldPath); if(photoFile.exists()){ //
				 * 设备ID[10数字]+原因(1byte)+时间[YYMMDDhhmmss].[jpg/wav] String
				 * newFileName =
				 * DeviceBiz.getDeviceCode().substring(2)+"_"+photoInfo
				 * .getEventCode()+"_"+photoInfo.getTime()+".jpg"; String newPath =
				 * copyFilePath+newFileName;
				 * FileOper.copyFileWithCreatePath(oldPath, newPath);
				 * bufWriter.write("照片文件名："+newFileName); bufWriter.newLine();
				 * //0：进入重车拍照 1：服务评价拍照 2：报警拍照 3：中心主动拍照 if(photoInfo.getEventCode()
				 * == 0){ bufWriter.write("拍照原因：进入重车拍照"); }else
				 * if(photoInfo.getEventCode() == 1){
				 * bufWriter.write("拍照原因：服务评价拍照"); }else if(photoInfo.getEventCode()
				 * == 2){ bufWriter.write("拍照原因：报警拍照"); }else
				 * if(photoInfo.getEventCode() == 3){
				 * bufWriter.write("拍照原因：中心主动拍照"); }else{
				 * bufWriter.write("拍照原因：其他"); } bufWriter.newLine();
				 * bufWriter.write("照片文件ID："+photoInfo.getMediaId());
				 * bufWriter.newLine();
				 * bufWriter.write("照片大小："+(photoInfo.getSize()-128));
				 * bufWriter.newLine(); bufWriter.newLine(); } } break;
				 */
				case TYPE_RECORDING:
					for (int i = 0; i < recorderInfos.size(); i++) {
						RecorderInfo recorderInfo = recorderInfos.get(i);

						String oldPath = Constants.RECORDING_PATH + "/" + recorderInfo.getTime() + ".mp3";
						File photoFile = new File(oldPath);
						if (photoFile.exists()) {
							// 设备ID[10数字]+原因(1byte)+时间[YYMMDDhhmmss].[jpg/wav]
							String newFileName = DeviceBiz.getDeviceCode().substring(2) + "_" + recorderInfo.getReason() + "_" + recorderInfo.getTime() + ".mp3";
							String newPath = copyFilePath + newFileName;
							FileOper.copyFileWithCreatePathForRecording(oldPath, newPath);
							bufWriter.write("录音文件名：" + newFileName);
							bufWriter.newLine();
							// // 0：正常录音；1：乘客投诉；2：报警录音
							if (recorderInfo.getReason() == 0) {
								bufWriter.write("录音原因：正常录音");
							} else if (recorderInfo.getReason() == 1) {
								bufWriter.write("录音原因：乘客投诉");
							} else if (recorderInfo.getReason() == 2) {
								bufWriter.write("录音原因：报警录音");
							} else {
								bufWriter.write("录音原因：其他");
							}
							bufWriter.newLine();
							bufWriter.write("录音文件ID：" + recorderInfo.getMediaId());
							bufWriter.newLine();
							bufWriter.write("录音大小：" + (recorderInfo.getSize() - 128));
							bufWriter.newLine();
							bufWriter.newLine();
						}
					}
					break;
				/*
				 * case TYPE_SERVICE_CARD: for(int i = 0;i<driverInfos.size();i++){
				 * DriverInfoBJ driver = driverInfos.get(i);
				 * bufWriter.write("司机姓名："+driver.getName()); bufWriter.newLine();
				 * if(driver.getTaxiStar() == 1){ bufWriter.write("星级：的星");
				 * bufWriter.newLine(); }else{ bufWriter.write("星级：非的星");
				 * bufWriter.newLine();
				 *
				 * }
				 *//** 从业资格类别 0x01：道路运输证； 0x02：从业资格证。 必须为02 */
				/*
				 * if(driver.getIcClass() == 2){ bufWriter.write("从业资格类别：从业资格证");
				 * bufWriter.newLine(); }else if(driver.getIcClass() == 1){
				 * bufWriter.write("从业资格类别：道路运输证"); bufWriter.newLine();
				 *
				 * }
				 *//** 0正常 1黑名单 2其他 */
				/*
				 * if(driver.getBlackInfo() == 0){ bufWriter.write("是否黑名单：否");
				 * bufWriter.newLine(); }else if(driver.getBlackInfo() == 1){
				 * bufWriter.write("是否黑名单：是"); bufWriter.newLine(); }else{
				 * bufWriter.write("是否黑名单：其他"); bufWriter.newLine(); }
				 * bufWriter.write("服务监督卡号："+driver.getCardCode());
				 * bufWriter.newLine();
				 * bufWriter.write("资格证号："+driver.getCertificateCode());
				 * bufWriter.newLine();
				 * bufWriter.write("有效期："+driver.getValidityDate());
				 * bufWriter.newLine();
				 * bufWriter.write("企业简称："+driver.getCompany());
				 * bufWriter.newLine();
				 * bufWriter.write("企业全称："+driver.getCompanyName());
				 * bufWriter.newLine();
				 * bufWriter.write("监督电话："+driver.getServiceTel());
				 * bufWriter.newLine();
				 * bufWriter.write("下次回公司开会时间："+driver.getNextMeetingTime());
				 * bufWriter.newLine();
				 * bufWriter.write("车牌号："+driver.getCarNumber());
				 * bufWriter.newLine();
				 *
				 * String oldPath = driver.getPhotoPath(); File photoFile = new
				 * File(oldPath); if(photoFile.exists()){
				 * bufWriter.write("照片文件名："+driver
				 * .getName()+driver.getCertificateCode()+".jpg"); String newPath =
				 * copyFilePath+driver.getName()+driver.getCertificateCode()+".jpg";
				 * FileOper.copyFileWithCreatePath(oldPath, newPath); }else{
				 * bufWriter.write("照片文件名：照片不存在"); } bufWriter.newLine();
				 * bufWriter.newLine();
				 *
				 * } break;
				 */
				case TYPE_DEVICE_PARAMS:
					String params = getParams();
					bufWriter.write("--------------------------- 参数 ---------------------------");
					bufWriter.write(params);
					break;

				default:
					break;
			}

			bufWriter.flush();
			filerWriter.flush();
			String tip = "";
			if (file.length() > 1024) {
				tip = file.length() / 1024 + "KB";
			} else {
				tip = file.length() + "B";
			}
			ToastUtils.showToastForCustom("导出成功！  " + tip);
			bufWriter.close();
			filerWriter.close();

		} catch (IOException e) {
			// TODO Auto-generated catch block
			ToastUtils.showToastForCustom("导出错误！");
			e.printStackTrace();
		}
	}

	private void doCheck() {
		// TODO Auto-generated method stub
		selectTime();
		switch (data_type) {
			case TYPE_BUSINESS:
				selectBusinessData();
				break;
			case TYPE_CHECKIN:
				selectCheckinData();
				break;
			case TYPE_CHECKOUT:
				selectCheckoutData();
				break;
			case TYPE_GPS:
				selectGpsData();
				break;
			case TYPE_PHOTO:
				// selectPhotoData();
				ToastUtils.showToastForCustom("暂不支持照片！");
				break;
			case TYPE_RECORDING:
				selectRecordData();
				break;
			case TYPE_SERVICE_CARD:
				// selectServiceCardData();
				ToastUtils.showToastForCustom("暂不支持司机信息！");
				break;
			case TYPE_DEVICE_PARAMS:
				showDataSize(1);
				break;

			default:
				break;
		}
	}

	private void selectTime() {
		// TODO Auto-generated method stub
		try {
			if (cb_stime.isChecked()) {
				String showTime = tv_start_time.getText().toString();
				sTime = DateUtil.getTime(showTime, DateUtil.df13, DateUtil.df8);

				long sTime = DateUtil.df13.parse(showTime).getTime();
				long currentTime = System.currentTimeMillis();
				if (sTime > currentTime) {
					ToastUtils.showToastForCustom("开始时间超前了", "#ff0000");
					return;
				}

			} else {
				sTime = "0";
			}
			if (cb_etime.isChecked()) {
				String showTime = tv_end_time.getText().toString();
				eTime = DateUtil.getTime(showTime, DateUtil.df13, DateUtil.df8);

				/*
				 * long eTime = DateUtil.df13.parse(showTime).getTime(); long
				 * currentTime = System.currentTimeMillis(); if(eTime >
				 * currentTime){ ToastUtils.showToastForCustom("结束时间超前了",
				 * "#ff0000"); return; }
				 */
				if (!cb_stime.isChecked()) {
					sTime = "100101000000";
				}
			} else {
				if (cb_stime.isChecked()) {
					eTime = DateUtil.getTodayDate(DateUtil.df8);
				} else {
					eTime = "0";
				}
			}
			if (cb_stime.isChecked() && cb_etime.isChecked()) {
				String sShowTime = tv_start_time.getText().toString();
				String eShowTime = tv_end_time.getText().toString();
				long sTime = DateUtil.df13.parse(sShowTime).getTime();
				long eTime = DateUtil.df13.parse(eShowTime).getTime();
				if (sTime >= eTime) {
					ToastUtils.showToastForCustom("开始时间必须小于结束时间！", "#ff0000");
					return;
				}
			}
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/*
	 * private void selectServiceCardData() { // TODO Auto-generated method stub
	 * if(driverInfoBiz == null){ driverInfoBiz = DriverInfoBiz.getInstance(); }
	 * driverInfos = driverInfoBiz.findAll(); if(driverInfos == null){
	 * showDataSize(0); }else{ showDataSize(driverInfos.size()); } }
	 */

	private void selectRecordData() {
		// TODO Auto-generated method stub
		if (recorderBiz == null) {
			recorderBiz = new RecorderBiz(this);
		}
		/**
		 * 录音原因 0:正常录音 1:乘客不满意投诉 2：报警录音
		 */
		int reason = recordReason - 1;
		recorderInfos = recorderBiz.findInfos(reason, sTime, eTime);
		if (recorderInfos == null) {
			showDataSize(0);
		} else {
			showDataSize(recorderInfos.size());
		}
	}

	/*
	 * private void selectPhotoData() { // TODO Auto-generated method stub
	 * if(photoInfoBiz == null){ photoInfoBiz = new PhotoInfoBiz(this); }
	 *//**
	 * 多媒体数据上传事件指令 0：进入重车拍照（抬表）； 1：服务评价拍照； 2：抢劫报警触发； 3：平台下发指令；
	 */
	/*
	 * int reason = photoReason-1; photoInfos =
	 * photoInfoBiz.findPhotoInfo(channelId, reason, sTime, eTime);
	 * if(photoInfos == null){ showDataSize(0); }else{
	 * showDataSize(photoInfos.size()); } }
	 */

	private void selectGpsData() {
		// TODO Auto-generated method stub
		if (localInfoBiz == null) {
			localInfoBiz = LocalInfoBiz.getInstance();
		}
		/** 上传状态 0：未上传 1：已上传 */
		int status = postStatus - 1;
		localInfos = localInfoBiz.getAllInfos(TYPE_GPS, status, sTime, eTime);
		if (localInfos == null) {
			showDataSize(0);
		} else {
			showDataSize(localInfos.size());
		}
	}

	private void selectCheckoutData() {
		// TODO Auto-generated method stub
		if (localInfoBiz == null) {
			localInfoBiz = LocalInfoBiz.getInstance();
		}
		/** 上传状态 0：未上传 1：已上传 */
		int status = postStatus - 1;
		localInfos = localInfoBiz.getAllInfos(TYPE_CHECKOUT, status, sTime, eTime);
		if (localInfos == null) {
			showDataSize(0);
		} else {
			showDataSize(localInfos.size());
		}
	}

	private void selectCheckinData() {
		// TODO Auto-generated method stub
		if (localInfoBiz == null) {
			localInfoBiz = LocalInfoBiz.getInstance();
		}
		/** 上传状态 0：未上传 1：已上传 */
		int status = postStatus - 1;
		localInfos = localInfoBiz.getAllInfos(TYPE_CHECKIN, status, sTime, eTime);
		if (localInfos == null) {
			showDataSize(0);
		} else {
			showDataSize(localInfos.size());
		}
	}

	private void selectBusinessData() {
		// TODO Auto-generated method stub
		if (localInfoBiz == null) {
			localInfoBiz = LocalInfoBiz.getInstance();
		}
		/** 上传状态 0：未上传 1：已上传 */
		int status = postStatus - 1;
		localInfos = localInfoBiz.getAllInfos(TYPE_BUSINESS, status, sTime, eTime);
		if (localInfos == null) {
			showDataSize(0);
		} else {
			showDataSize(localInfos.size());
		}
	}

	private void showDataSize(int size) {
		// TODO Auto-generated method stub
		tv_count.setText("共找到" + size + "条数据");
	}

	private WheelMain wheelMain;
	private Calendar calendar;
	private Calendar calendarST;
	private Calendar calendarET;
	private int year;
	private int month;
	private int day;
	private int h;
	private int m;

	/** 选择时间 */
	private void choiceTime(final TextView tv) {
		// TODO Auto-generated method stub
		String title = "";
		if (tv.getId() == R.id.tv_start_time) {
			title = "设置开始时间";
			calendar = calendarST;
		} else {
			calendar = calendarET;
			title = "设置结束时间";
		}
		LayoutInflater inflater = LayoutInflater.from(this);
		final View timepickerview = inflater.inflate(R.layout.datepicker, null);
		ScreenInfo screenInfo = new ScreenInfo(this);
		wheelMain = new WheelMain(timepickerview, true);
		wheelMain.screenheight = screenInfo.getHeight();

		year = calendar.get(Calendar.YEAR);
		month = calendar.get(Calendar.MONTH);
		day = calendar.get(Calendar.DAY_OF_MONTH);
		h = calendar.get(Calendar.HOUR_OF_DAY);
		m = calendar.get(Calendar.MINUTE);

		wheelMain.initDateTimePicker(year, month, day, h, m);
		wheelMain.setTextSize(26, 30);
		new AlertDialog.Builder(this).setTitle(title).setView(timepickerview).setPositiveButton("确定", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// tv.setText(wheelMain.getTime());
				tv.setText(DateUtil.dateFormatForTimePicker(wheelMain.getTime()));
				try {
					if (tv.getId() == R.id.tv_start_time) {
						String startTime = tv_start_time.getText().toString();
						long sTime = DateUtil.df13.parse(startTime).getTime();
						calendarST.setTimeInMillis(sTime);
					} else {
						String endTime = tv_end_time.getText().toString();
						long eTime = DateUtil.df13.parse(endTime).getTime();
						calendarET.setTimeInMillis(eTime);
					}
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		}).show();
	}

	/**
	 * 查询参数设置
	 *
	 * @param paramId
	 *            参数id
	 */
	private static String getParams() {
		// TODO Auto-generated method stub
		StringBuilder builder = new StringBuilder();
		builder.append("\n");
		builder.append("\nISU心跳发送间隔，单位为秒（s）：" + DeviceBiz.getHeartTime());

		int paramValue0002 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_TCP_TIME_OUT, 5);
		builder.append("\nTCP消息应答超时时间，单位为秒（s）：" + paramValue0002);

		int paramValue0003 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_TCP_RESEND_COUNT, 3);
		builder.append("\nTCP消息重传次数：" + paramValue0003);

		int paramValue0004 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_SMS_TIME_OUT, 5);
		builder.append("\nSMS消息应答超时时间，单位为秒（s）：" + paramValue0004);

		int paramValue0005 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_SMS_RESEND_COUNT, 3);
		builder.append("\nSMS消息重传次数：" + paramValue0005);

		String paramValue0010 = SPUtils.defaultPref().getString(SPConstants.PARAMS_SERVER_APN, "");
		builder.append("\n主服务器APN：" + paramValue0010);

		String paramValue0011 = SPUtils.defaultPref().getString(SPConstants.PARAMS_MAIN_USER, "");
		builder.append("\n主服务器无线通信拨号用户名：" + paramValue0011);

		String paramValue0012 = SPUtils.defaultPref().getString(SPConstants.PARAMS_MAIN_PWD, "");
		builder.append("\n主服务器无线通信拨号密码：" + paramValue0012);

		builder.append("\n主服务器地址,IP或域名：" + DeviceBiz.getIp());

		String paramValue0014 = SPUtils.defaultPref().getString(SPConstants.PARAMS_SERVER_APN_BAK, "");
		builder.append("\n备份服务器APN：" + paramValue0014);

		String paramValue0015 = SPUtils.defaultPref().getString(SPConstants.WIRELESS_USER_NAME_BAK, "");
		builder.append("\n副服务器无线通信拨号用户名：" + paramValue0015);

		String paramValue0016 = SPUtils.defaultPref().getString(SPConstants.WIRELESS_USER_PASSWORD_BAK, "");
		builder.append("\n副服务器无线通信拨号密码：" + paramValue0016);

		builder.append("\n备份服务器地址,IP或域名：" + DeviceBiz.getIpBak());

		builder.append("\n主服务器TCP端口：" + DeviceBiz.getPort());

		builder.append("\n备份服务器TCP端口：" + DeviceBiz.getPortBak());

		String paramValue001A = SPUtils.defaultPref().getString(SPConstants.ONE_CARD_SERVER_IP, "");
		builder.append("\n一卡通或支付平台主服务器地址,IP或域名：" + paramValue001A);

		int paramValu001B = SPUtils.defaultPref().getInt(SPConstants.ONE_CARD_SERVER_IP_PORT, 0);
		builder.append("\n备份服务器UCP端口：" + paramValu001B);

		String paramValue001C = SPUtils.defaultPref().getString(SPConstants.ONE_CARD_SERVER_IP_BAK, "");
		builder.append("\n一卡通或支付平台备份服务器地址IP或域名：" + paramValue001C);

		int paramValue001D = SPUtils.defaultPref().getInt(SPConstants.ONE_CARD_SERVER_IP_PORT_BAK, 0);
		builder.append("\n一卡通或支付平台备份服务器TCP端口：" + paramValue001D);

		int paramValue0020 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_POSITION_REPORT_TYPE, 0);
		String item0020 = "";
		switch (paramValue0020) {
			case 0:
				item0020 = "0：定时汇报";
				break;
			case 1:
				item0020 = "1：定距汇报";
				break;
			case 2:
				item0020 = "2：定时 + 定距汇报";
				break;
			default:
				break;
		}
		builder.append("\n位置汇报策略：" + item0020);

		int paramValue0021 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_POSITION_REPORT_MODE, 3);
		String item0021 = "";
		switch (paramValue0021) {
			case 0:
				item0021 = "0：根据ACC状态";
				break;
			case 1:
				item0021 = "1：根据空重车状态";
				break;
			case 2:
				item0021 = "2：根据登录状态 + ACC状态，先判断登录状态，若登录再根据ACC状态";
				break;
			case 3:
				item0021 = "3：根据登录状态 + 空重车状态，先判断登录状态，若登录再根据空重车状态";
				break;
			default:
				break;
		}
		builder.append("\n位置汇报方案：" + item0021);

		builder.append("\n未登录汇报时间间隔，单位为秒（s）：" + DeviceBiz.getOffLineHeartTime());

		int paramValue0023 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ACC_OFF_REPORT_TIME, 30);
		builder.append("\nACC OFF汇报时间间隔，单位为秒（s）：" + paramValue0023);

		int paramValue0024 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ACC_ON_REPORT_TIME, 30);
		builder.append("\nACC ON汇报时间间隔，单位为秒（s）：" + paramValue0024);

		builder.append("\n空车汇报时间间隔，单位为秒（s）：" + DeviceBiz.getEmptyCarHeartTime());

		builder.append("\n重车汇报时间间隔，单位为秒（s）：" + DeviceBiz.getFullCarHeartTime());

		int paramValue0027 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_DORMANT_REPORT_TIME, 30);
		builder.append("\n休眠时汇报时间间隔，单位为秒（s）：" + paramValue0027);

		int paramValue0028 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_URGENCY_ALARM_REPORT_TIME, 30);
		builder.append("\n紧急报警时汇报时间间隔，单位为秒（s）：" + paramValue0028);

		int paramValue0029 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_OFFLINE_REPORT_DISTANCE, 500);
		builder.append("\n未登录汇报距离间隔，单位为秒（s）：" + paramValue0029);

		int paramValue002A = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ACC_OFF_REPORT_DISTANCE, 500);
		builder.append("\nACC OFF汇报距离间隔，单位为米（m）：" + paramValue002A);

		int paramValue002B = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ACC_ON_REPORT_DISTANCE, 500);
		builder.append("\nACC ON汇报距离间隔，单位为米（m）：" + paramValue002B);

		int paramValue002C = SPUtils.defaultPref().getInt(SPConstants.PARAMS_EMPTY_REPORT_DISTANCE, 500);
		builder.append("\n空车汇报距离间隔，单位为米（m）：" + paramValue002C);

		int paramValue002D = SPUtils.defaultPref().getInt(SPConstants.PARAMS_FULL_REPORT_DISTANCE, 500);
		builder.append("\n重车汇报距离间隔，单位为米（m）：" + paramValue002D);

		int paramValue002E = SPUtils.defaultPref().getInt(SPConstants.PARAMS_DORMANT_REPORT_DISTANCE, 500);
		builder.append("\n休眠时汇报距离间隔，单位为米（m）：" + paramValue002E);

		int paramValue002F = SPUtils.defaultPref().getInt(SPConstants.PARAMS_URGENCY_ALARM_REPORT_DISTANCE, 500);
		builder.append("\n紧急报警时汇报距离间隔，单位为米（m）：" + paramValue002F);

		String paramValue0030 = SPUtils.defaultPref().getString(SPConstants.PARAMS_FILL_THE_ANGLE, "");
		builder.append("\n拐点补传角度，<180°：" + paramValue0030);

		String paramValue0040 = SPUtils.defaultPref().getString(SPConstants.PARAMS_CENTRA_PHONE, "13911100999");
		builder.append("\n监控指挥中心电话号码：" + paramValue0040);

		String paramValue0041 = SPUtils.defaultPref().getString(SPConstants.PARAMS_RESET_PHONE, "13911100999");
		builder.append("\n复位电话号码：" + paramValue0041);

		String paramValue0042 = SPUtils.defaultPref().getString(SPConstants.PARAMS_RESET_FIRST_PHONE, "13911100999");
		builder.append("\n恢复出厂设置电话号码：" + paramValue0042);

		String paramValue0043 = SPUtils.defaultPref().getString(SPConstants.PARAMS_CENTRA_SMS_PHONE, "13911100999");
		builder.append("\n监控指挥中心SMS电话号码：" + paramValue0043);

		String paramValue0044 = SPUtils.defaultPref().getString(SPConstants.PARAMS_SMS_ALARM_PHONE, "");
		builder.append("\n接收ISUSMS文本报警号码：" + paramValue0044);

		int paramValue0045 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ANSWER_CALL_TYPE, 0);
		if (paramValue0045 == 0) {
			builder.append("\nISU电话接听策略：0：自动接听");
		} else if (paramValue0045 == 1) {
			builder.append("\nISU电话接听策略： 1：ACC ON时自动接听，OFF时手动接听");
		} else {
			builder.append("\nISU电话接听策略：其他");
		}

		builder.append("\n每次最长通话时间，单位为秒（s）：" + DeviceBiz.getMaxCall());

		int paramValue0047 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_MAX_CALL_MONTH_TIME, 30 * 24 * 60 * 60);
		builder.append("\n当月最长通话时间，单位为秒（s）：" + paramValue0047);

		int paramValue0048 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_SHORT_LENGTH, 0);
		builder.append("\n电话短号长度：" + paramValue0048);

		String paramValue0049 = SPUtils.defaultPref().getString(SPConstants.PARAMS_MONITOR_PHONE, "13911100999");
		builder.append("\n监听电话号码：" + paramValue0049);

		builder.append("\nISU设备维护密码：" + Constants.VALIDATION_PASSWD);

		builder.append("\nISU的语音播报音量控制：0～9 （0为静音，9为最高）：" + 5);

		int paramValue0050 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ALARM_FLAG, 0);
		builder.append("\n报警屏蔽字，与位置信息汇报消息中的报警标志相对应，相应位为1则相应报警被屏蔽：" + paramValue0050);

		int paramValue0051 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ALARM_SMS_SWITCHER, 0);
		builder.append("\n报警发送文本SMS开关，与位置信息汇报消息中的报警标志相对应，相应位为1则相应报警时发送文本SMS：" + paramValue0051);

		int paramValue0052 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ALARM_FILM_SWITCHER, 1);
		builder.append("\n报警拍摄开关，与位置信息汇报消息中的报警标志相对应，相应位为1则相应报警时摄像头拍摄：" + paramValue0052);

		int paramValue0053 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ALARM_FILM_SAVE_SWITCHER, 1);
		builder.append("\n报警拍摄存储标志，与位置信息汇报消息中的报警标志相对应，相应位为1则对相应报警时拍的照片进行存储，否则实时上传：" + paramValue0053);

		int paramValue0055 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_MAX_SPEED, 120);
		builder.append("\n最高速度，单位为千米每小时（km/h）：" + paramValue0055);

		int paramValue0056 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_SPEEDING_TIME, 30);
		builder.append("\n超速持续时间，单位为秒（s）：" + paramValue0056);

		int paramValue0057 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_MAX_RUN_TIME, 2 * 60 * 60);
		builder.append("\n连续驾驶时间门限，单位为秒（s）：" + paramValue0057);

		int paramValue0058 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_MIN_REST_TIME, 10 * 60);
		builder.append("\n最小休息时间，单位为秒（s）：" + paramValue0058);

		int paramValue0059 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_MAX_PART_TIME, 30 * 60);
		builder.append("\n最长停车时间，单位为秒（s）：" + paramValue0059);

		int paramValue005A = SPUtils.defaultPref().getInt(SPConstants.PARAMS_MAX_DAILY_RUN_TIME, 12 * 60 * 60);
		builder.append("\n当天累计驾驶时间门限，单位为秒（s）：" + paramValue005A);

		int paramValue005B = SPUtils.defaultPref().getInt(SPConstants.PARAMS_PHOTOGRAPH_TRIGGER, 0);
		builder.append("\n事件触发拍照控制，参见附录D：" + paramValue005B);

		int paramValue005C = SPUtils.defaultPref().getInt(SPConstants.PARAMS_PICTRUE_SAVE, 0);
		builder.append("\n拍照存储控制，参见表附录D：" + paramValue005C);

		int paramValue0070 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_VEDIO_LEVEL, 2);
		builder.append("\n图像/视频质量，1～10，1最好：" + paramValue0070);

		int paramValue0071 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_BRIGHTNESS, 200);
		builder.append("\n亮度，0～255：" + paramValue0071);

		int paramValue0072 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_CONTRAST, 127);
		builder.append("\n对比度，0～127：" + paramValue0072);

		int paramValue0073 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_SATURABILITY, 127);
		builder.append("\n饱和度，0～127：" + paramValue0073);

		int paramValue0074 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_CHROMINANCE, 255);
		builder.append("\n色度，0～255：" + paramValue0074);

		builder.append("\n车辆里程表读数，0.1km：" + 0);

		int paramValue0081 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_CURRENT_PROVINCE, 11);
		builder.append("\n车辆所在的省域ID，1～255：" + paramValue0081);

		int paramValue0082 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_CURRENT_CITY, 112);
		builder.append("\n车辆所在的市域ID，1～255：" + paramValue0082);

		builder.append("\n计价器营运次数限制，0～9999；0表示不做限制：" + 0);

		builder.append("\n计价器营运时间限制，YYYYMMDDHH，0000000000表示不做限制：" + "0000000000");

		builder.append("\n出租车企业营运许可证号：" + DataUtil.getCompanyCode());

		builder.append("\n出租车企业简称：导航科技");

		builder.append("\n出租车车牌号码(不包括汉字)：" + DeviceBiz.getCarNumberSingleLetter());

		builder.append("\n单位代码（老格式，兼容备用）：" + DataUtil.getCompanyCode());

		builder.append("\n计价器远程锁定0开1关：" + 1);

		builder.append("\n与中心中断允许运营时间，单位：小时，全0表示无时间限制：" + 0);

		builder.append("\n 智能终端录音模式（OXO1全程录音;0X02:翻牌录音)：" + RecorderBiz.getRecordType());

		builder.append("\n智能终端录音文件最大时长（1-255)分钟：" + RecorderBiz.getMaxTime());

		int paramValue00A2 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_LCD_HEARTBEAT_TIME, 60);
		builder.append("\n液晶（LCD）心跳时间间隔，1～60，单位为秒（s）：" + paramValue00A2);

		int paramValue00A3 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_LED_HEARTBEAT_TIME, 60);
		builder.append("\nLED心跳时间间隔，单位为秒（s）：" + paramValue00A3);

		int paramValue00AF = SPUtils.defaultPref().getInt(SPConstants.PARAMS_ACC_OFF_DORMANT_TIME, 10);
		builder.append("\nACC OFF后进入休眠模式的时间，单位为秒（s）：" + paramValue00AF);

		int paramValue00B0 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_VEDIO_PROTOCOL_MODE, 0);
		builder.append("\n视频服务器协议模式 0x00：TCP；0x01：UDP：" + paramValue00B0);

		String paramValue00B1 = SPUtils.defaultPref().getString(SPConstants.PARAMS_VEDIO_ADDR, "");
		builder.append("\n视频服务器APN，无线通信拨号访问点：" + paramValue00B1);

		String paramValue00B2 = SPUtils.defaultPref().getString(SPConstants.PARAMS_VEDIO_USER_NAME, "");
		builder.append("\n视频服务器无线通信拨号用户名：" + paramValue00B2);

		String paramValue00B3 = SPUtils.defaultPref().getString(SPConstants.PARAMS_VEDIO_USER_PASSWORD, "");
		builder.append("\n视频服务器无线通信拨号密码：" + paramValue00B3);

		String paramValue00B4 = SPUtils.defaultPref().getString(SPConstants.PARAMS_VEDIO_IP, "");
		builder.append("\n视频服务器地址,IP或域名：" + paramValue00B4);

		int paramValue00B5 = SPUtils.defaultPref().getInt(SPConstants.PARAMS_VEDIO_PORT, 0);
		builder.append("\n视频服务器端口：" + paramValue00B5);
		return builder.toString();
	}

	private String getClearShowData(int dataType, LocalInfo info) {
		// TODO Auto-generated method stub
		String clearSHowData = null;
		if (dataType == TYPE_BUSINESS) {
			clearSHowData = getClearBusinessData(info);
		} else if (dataType == TYPE_CHECKIN) {
			clearSHowData = getClearCheckInData(info.getData());
		}
		if (dataType == TYPE_CHECKOUT) {
			clearSHowData = getClearCheckOutData(info.getData());
		}
		if (dataType == TYPE_GPS) {
			clearSHowData = getClearGpsData(info.getData());
		}
		return clearSHowData;
	}

	private String getClearBusinessData(LocalInfo info) {
		// TODO Auto-generated method stub
		StringBuilder builder = new StringBuilder();
		byte[] businessData = Tools.parseHexStr2Byte(info.getData());
		businessData = Tools.yxReversal(businessData);

		int num = 13;
		// 空转重位置信息
		num += 25;
		// 重转空位置信息
		num += 25;

		// 营运ID UINT32
		long yyid = 0;
		try {
			yyid = Long.parseLong(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		} catch (Exception e) {
			e.printStackTrace();
		}
		num += 4;
		// 评价ID UINT32
		long pjid = Long.parseLong(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		num += 4;
		// 评价选项 UINT8
		int pjxx = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 1)), 16);
		num += 1;
		// 评价选项扩展 UINT16
		num += 2;
		// 电召订单ID UINT32 0：正常营运数据；非0标识电召营运数据
		int ddid = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		num += 4;
		String ddidStr = "正常营运数据";
		if (ddid == 1) {
			ddidStr = "电召营运数据";
		}
		// 车牌号 BYTE[6]
		String cph = Tools.byteToString(businessData, num, 6);
		num += 6;
		// 经营许可证号（立户号） BYTE [16]
		String lhh = Tools.byteToString(businessData, num, 16);
		num += 16;
		// 驾驶员从业资格证号 BYTE[19]
		num += 19;
		// 41 上车时间 BCD[5] 格式为YY-MM-DD-hh-mm
		String sTime = Tools.bcd2Str(Tools.byteTobyte(businessData, num, 5));
		sTime = sTime + "00";
		sTime = DateUtil.getTime(sTime, DateUtil.df8, DateUtil.df12);
		num += 5;
		// 下车时间 BCD[2] 格式为hh-mm
		String eTime = Tools.bcd2Str(Tools.byteTobyte(businessData, num, 2));
		if (eTime.length() == 3) {
			eTime = "0" + eTime;
		}
		eTime = eTime + "00";
		eTime = DateUtil.getTime(eTime, DateUtil.df19, DateUtil.df12);
		num += 2;
		// 48 计程公里 BCD[3] 格式为XXXXX.Xkm
		BigDecimal decimaMil = new BigDecimal(Tools.bcd2Str(Tools.byteTobyte(businessData, num, 3)));
		decimaMil = decimaMil.divide(new BigDecimal(10));
		String milege = DecimalUtil.priceFormat(decimaMil.doubleValue());
		num += 3;
		// 51 空驶里程 BCD[2] 格式为XXX.Xkm
		BigDecimal emptyMil = new BigDecimal(Tools.bcd2Str(Tools.byteTobyte(businessData, num, 2)));
		emptyMil = emptyMil.divide(new BigDecimal(10));
		String emptyMilege = DecimalUtil.priceFormat(emptyMil.doubleValue());
		num += 2;
		// 附加费 BCD[3] 格式XXXXX.X元
		num += 3;
		// 等待计时时间 BCD[2] 格式为hh-mm
		String waitTime = Tools.bcd2Str(Tools.byteTobyte(businessData, num, 2));
		if (waitTime.length() == 3) {
			waitTime = "0" + waitTime;
		}
		waitTime = waitTime + "00";
		waitTime = DateUtil.getTime(waitTime, DateUtil.df19, DateUtil.df12);
		num += 2;
		// 70 交易金额 BCD[3] 格式XXXXX.X元（总金额）
		BigDecimal decimal = new BigDecimal(Tools.bcd2Str(Tools.byteTobyte(businessData, num, 3)));
		decimal = decimal.divide(new BigDecimal(10));
		String amount = DecimalUtil.priceFormat(decimal.doubleValue());
		num += 3;
		// 74 当前车次 UINT32
		int carCount = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		num += 4;
		// 78 账单类型 BYTE
		int payType = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 1)), 16);
		System.out.println("payType----------------:" + payType);

		/*
		 * if(info.getStatus() == 0){ //未上传
		 * tv_amount.setTextColor(Color.parseColor("#FF0000")); }else{
		 * tv_amount.setTextColor(Color.parseColor("#FEE801")); }
		 */
		String payTypeStr = "";
		if (payType == 0) {
			payTypeStr = "现金";
		} else if (payType == 1) {
			payTypeStr = "M1卡";
		} else if (payType == 3) {
			payTypeStr = "CPU卡";
		} else if (payType == 9) {
			payTypeStr = "其他";
		}

		builder.append("\n数据库车次：" + info.getCarTimes()).append("\n营运ID：" + yyid).append("\n评价ID：" + pjid).append("\n评价选项：" + pjxxs[pjxx]).append("\n电召订单ID：" + ddidStr)

				.append("\n车牌号：" + cph).append("\n经营许可证号：" + lhh).append("\n\n车次：" + carCount).append("\n上车时间：" + sTime).append("\n下车时间：" + eTime).append("\n等候时间：" + waitTime).append("\n计程公里：" + milege)
				.append("\n空驶公里：" + emptyMilege).append("\n交易金额：" + amount.substring(0, amount.indexOf(".")) + "元").append("\n\n账单类型：" + payTypeStr);

		// return Tools.parseByte2HexStr(businessData);
		return builder.toString();
	}

	/**
	 * 0：往返状态；1：单程状态
	 */
	private String[] wfzts = { "往返状态", "单程状态" };

	/**
	 * 0x00：现金交易账单； 0x01：一卡通公交卡交易账单； 0x02：银联闪付卡交易账单。
	 */
	private String[] zdlxs = { "现金交易账单", "一卡通公交卡交易账单", "银联闪付卡交易账单", "银联二维码支付账单" };

	/**
	 * 0x00：没有做出评价；0x01：非常满意；0x02：满意；0x03：一般；0x04：不满意
	 */
	private String[] pjxxs = { "没有做出评价", "非常满意", "满意", "一般", "不满意" };

	/**
	 * 0：无混付； 1：混付第1笔； 2：混付第2笔； n：混付第n笔；
	 */
	private String[] hfzts = { "无混付", "混付第1笔", "混付第2笔", "混付第3笔", "混付第4笔", "混付第5笔" };

	/**
	 * 0：独乘； 1：合乘第1个乘客； 2：合乘第2个乘客； 3：合乘第3个乘客； 4：合乘第4个乘客；
	 */
	private String[] hczts = { "独乘", "合乘第1个乘客", "合乘第2个乘客", "合乘第3个乘客", "合乘第4个乘客", "合乘第5个乘客" };

	/**
	 * 0x01：独乘和合乘最后一个乘客 其他：非独乘、非最后一个乘客
	 *
	 * @param pj
	 * @return
	 */
	private String getIsEndText(int isEnd) {
		String text = "非独乘、非最后一个乘客";
		if (isEnd == 1) {
			text = "独乘和合乘最后一个乘客";
		}
		return text;
	}

	private String getClearCheckInData(String data) {
		// TODO Auto-generated method stub
		StringBuilder builder = new StringBuilder();
		try {
			byte[] businessData = Tools.parseHexStr2Byte(data);
			businessData = Tools.yxReversal(businessData);
			if (businessData.length < 10) {
				return null;
			}
			int num = 0;
			num += 13 + 25;

			// 单位代码
			String company = Tools.byteToString(businessData, num, 16);
			num += 16;
			// 从业资格证号
			String driverCode = Tools.byteToString(businessData, num, 19);
			num += 19;
			// 车牌号
			String carNumber = Tools.byteToStringASCII(businessData, num, 6);
			num += 6;
			// 计价器开机时间 YYYY-MM-DD-hh-mm
			String time = Tools.bcd2Str(Tools.byteTobyte(businessData, num, 6));
			num += 6;
			time = DateUtil.getTime(time, DateUtil.df2, DateUtil.df11);
			builder.append("\n经营许可证号：" + company).append("\n从业资格证号：" + driverCode).append("\n车牌号：" + carNumber).append("\n开机时间：" + time);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return builder.toString();
	}

	private String getClearCheckOutData(String data) {
		// TODO Auto-generated method stub
		StringBuilder builder = new StringBuilder();
		byte[] dataContent = Tools.parseHexStr2Byte(data);
		dataContent = Tools.yxReversal(dataContent);
		int num = 0;
		num += 13 + 25;

		// 单位代码 BCD[16]
		String companyCode = Tools.byteToString(dataContent, num, 16);
		num += 16;
		// 司机代码 BCD[19] 车辆自编号+司机编码，6位，不足的前面补0
		String driverCode = Tools.byteToString(dataContent, num, 19);
		num += 19;
		// 车牌号 BYTE[6] 车辆自编号，5位，前面补0，ASCII字符
		String carNum = Tools.byteToString(dataContent, num, 6);
		num += 6;
		// 计价器K值 BCD[2] 格式为XXXX，最大9999，暂时填0
		String valueK = "" + Integer.parseInt(Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 2)));
		num += 2;
		// 当班开机时间 BCD[6] YYYY-MM-DD-hh-mm
		String stime = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 6));
		num += 6;
		// 当班关机时间 BCD[6] YYYY-MM-DD-hh-mm
		String etime = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 6));
		num += 6;
		// 当班公里 BCD[3] 格式为XXXXX.X公里
		String dbgl = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 3));
		num += 3;
		// 当班营运公里 BCD[3] 格式为XXXXX.X公里
		String dbyygl = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 3));
		num += 3;
		// 车次 BCD[2] 格式为XXXX，最大9999（保留，填0）
		int count = Integer.parseInt(Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 2)));
		num += 2;
		// 计时时间 BCD[3] hh-mm-ss（总计费时间），是部标内容，有业务需求，请确认能否上传
		String jssj = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 3));
		num += 3;
		// 总计金额 BCD[3] 格式XXXXX.X元
		String amount = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 3));
		num += 3;
		// 卡收金额 BCD[3] 格式XXXXX.X元
		String ksje = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 3));
		num += 3;
		// 卡次 BCD[2] 袼式为XXKX，最大9999
		int countCard = Integer.parseInt(Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 2)));
		num += 2;
		// 班间公里 BCD[2] 格式XXX.X公里（上一班签退到本班签 到的公里数）
		String bjgl = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 2));
		num += 2;
		// 总计公里 BCD[4] 格式为XXXXX.X公里（计价器安装后累积）
		String zjgl = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 4));
		num += 4;
		// 总营运公里 BCD[4] 格式为XXXXX.X公里（计价器安装后累积）
		String zyygl = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 4));
		num += 4;
		// 单价 BCD[2] 格式XX.XX元
		String dj = Tools.bcd2Str(Tools.byteTobyte(dataContent, num, 2));
		num += 2;
		// 总营运次数 UINT32 高位在前，低位在后
		int countAll = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(dataContent, num, 4)), 16);
		num += 4;

		stime = DateUtil.getTime(stime, DateUtil.df2, DateUtil.df11);
		etime = DateUtil.getTime(etime, DateUtil.df2, DateUtil.df11);

		BigDecimal decimal = new BigDecimal(amount);
		decimal = decimal.divide(new BigDecimal(10));
		double subAmount = decimal.doubleValue();

		jssj = DateUtil.getTime(jssj, DateUtil.df19, DateUtil.df12);
		BigDecimal decimal2 = new BigDecimal(ksje);
		decimal2 = decimal2.divide(new BigDecimal(10));
		double ksjeD = decimal2.doubleValue();
		if (Integer.parseInt(zyygl) == 0) {
			zyygl = "0.00";
		} else {
			BigDecimal bigDecimal = new BigDecimal(zyygl);
			bigDecimal = bigDecimal.divide(new BigDecimal(10));
			zyygl = DecimalUtil.priceFormat(bigDecimal.doubleValue());
		}
		if (Integer.parseInt(zjgl) == 0) {
			zjgl = "0.00";
		} else {
			BigDecimal bigDecimal = new BigDecimal(zjgl);
			bigDecimal = bigDecimal.divide(new BigDecimal(10));
			zjgl = DecimalUtil.priceFormat(bigDecimal.doubleValue());
		}
		if (Integer.parseInt(dbgl) == 0) {
			dbgl = "0.00";
		} else {
			BigDecimal bigDecimal = new BigDecimal(dbgl);
			bigDecimal = bigDecimal.divide(new BigDecimal(10));
			dbgl = DecimalUtil.priceFormat(bigDecimal.doubleValue());
		}
		if (Integer.parseInt(dbyygl) == 0) {
			dbyygl = "0.00";
		} else {
			BigDecimal bigDecimal = new BigDecimal(dbyygl);
			bigDecimal = bigDecimal.divide(new BigDecimal(10));
			dbyygl = DecimalUtil.priceFormat(bigDecimal.doubleValue());
		}
		if (Integer.parseInt(bjgl) == 0) {
			bjgl = "0.00";
		} else {
			BigDecimal bigDecimal = new BigDecimal(bjgl);
			bigDecimal = bigDecimal.divide(new BigDecimal(10));
			bjgl = DecimalUtil.priceFormat(bigDecimal.doubleValue());
		}
		if (Integer.parseInt(dj) == 0) {
			dj = "0.00";
		} else {
			BigDecimal bigDecimal = new BigDecimal(dj);
			bigDecimal = bigDecimal.divide(new BigDecimal(100));
			dj = DecimalUtil.priceFormat(bigDecimal.doubleValue());
		}
		builder.append("经营许可证号：" + companyCode).append("\n驾驶员从业资格证号：" + driverCode).append("\n车牌号：" + carNum).append("\nK值：" + valueK).append("\n当班开机时间：" + stime).append("\n当班关机时间：" + etime).append("\n当班里程：" + dbgl)
				.append("\n当班营运里程：" + dbyygl).append("\n当班车次：" + count).append("\n当班计时时间：" + jssj).append("\n当班总计金额：" + DecimalUtil.priceFormat(subAmount)).append("\n当班卡收金额：" + DecimalUtil.priceFormat(ksjeD))
				.append("\n当班卡次：" + countCard).append("\n班间里程：" + bjgl).append("\n总计里程：" + zjgl).append("\n总营运里程：" + zyygl).append("\n单价：" + dj).append("\n总营运次数：" + countAll);
		return builder.toString();
	}

	private String getClearGpsData(String data) {
		// TODO Auto-generated method stub
		StringBuilder builder = new StringBuilder();
		byte[] businessData = Tools.parseHexStr2Byte(data);
		businessData = Tools.yxReversal(businessData);
		int num = 0;
		// 报警标志 UINT32
		int bjbz = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		num += 4;
		// 状态 UINT32
		int zt = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		num += 4;
		// 纬度 UINT32
		int wdInt = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		double wd = wdInt * 1E-6;
		num += 4;
		// 经度 UINT32
		int jdInt = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
		double jd = jdInt * 1E-6;
		num += 4;
		// 速度 UINT16
		double sd = (double) Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 2)), 16);
		num += 2;
		// 方向 UINT8
		int fx = Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 1)), 16);
		num += 1;
		// 时间 BCD[6] YYMMDDhhmmss
		String sj = Tools.bcd2Str(Tools.byteTobyte(businessData, num, 6));
		sj = DateUtil.getTime("20" + sj, DateUtil.df6, DateUtil.df1);
		num += 6;
		double mileage = 0;
		if (businessData.length > 25) {
			try {
				num += 2;
				mileage = (double) Integer.parseInt(Tools.parseByte2HexStr(Tools.byteTobyte(businessData, num, 4)), 16);
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		builder.append("时间：" + sj).append("\n经度：" + jd).append("\n纬度：" + wd).append("\n方向：" + fx).append("\n速度：" + (sd / 10.0)).append("\n里程：" + (mileage / 10.0) + "\n");

		/** 报警标志 */
		String alarm = StringUtil.getAntitone(Tools.byteTobit(Tools.sortToByte(Tools.int2Bytes(bjbz, 4))));
		int[] alarms = new int[29];
		for (int i = 0; i < alarms.length; i++) {
			int indexAlarm = Integer.parseInt(String.valueOf(alarm.charAt(i)));
			String indexText = alarmText[i];
			String indexAlarmText = stateText[indexAlarm];

			builder.append("\n" + indexText + "：" + indexAlarmText);
		}

		/** 状态标志 */
		String state = StringUtil.getAntitone(Tools.byteTobit(Tools.sortToByte(Tools.int2Bytes(zt, 4))));
		int numState = 0;
		// 0 0：已卫星定位；1：未卫星定位
		int indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n\n卫星定位状态：已定位");
		} else {
			builder.append("\n卫星定位状态：未定位");
		}
		// 1 0：北纬；1：南纬
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n南北纬：北纬");
		} else {
			builder.append("\n南北纬：南纬");
		}
		// 2 0：东经；1：西经
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n东西经：东经");
		} else {
			builder.append("\n东西经：西经");
		}
		// 3 0：运营状态；1：停运状态
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n营运状态：营运");
		} else {
			builder.append("\n营运状态：停运");
		}
		// 4 0：未预约；1：预约（任务车）
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n预约状态：未预约");
		} else {
			builder.append("\n预约状态：预约");
		}
		// 5 0：默认；1.空转重
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n空转重：默认");
		} else {
			builder.append("\n空转重：空转重");
		}
		// 6 0：默认；1.重转空
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n重转空：默认");
		} else {
			builder.append("\n重转空：重转空");
		}
		// 7 预留
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		// 8 0：ACC关；1：ACC开
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\nACC状态：ACC关");
		} else {
			builder.append("\nACC状态：ACC开");
		}
		// 9 0：空车；1：重车
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n空重状态：空车");
		} else {
			builder.append("\n空重状态：重车");
		}
		// 10 0：车辆油路正常；1：车辆油路断开
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n车辆油路状态：正常");
		} else {
			builder.append("\n车辆油路状态：断开");
		}
		// 11 0：车辆电路正常；1：车辆电路断开
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n车辆电路状态：正常");
		} else {
			builder.append("\n车辆电路状态：断开");
		}
		// 12 0：车门解锁；1：车门加锁
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n车门状态：解锁");
		} else {
			builder.append("\n车门状态：加锁");
		}
		// 13 0：车辆未锁定；1：车辆锁定
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n车辆状态：未锁定");
		} else {
			builder.append("\n车辆状态：锁定");
		}
		// 14 0：未到达限制营运次数/时间；1：已达到限制营运次数/时间
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n限制营运次数：未达到");
		} else {
			builder.append("\n限制营运次数：已达到");
		}
		// 15 电召状态，0：未电召；1：电召
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n电召状态：未电召");
		} else {
			builder.append("\n电召状态：电召");
		}
		// 16 调度状态，0：未调度；1：调度
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n调度状态：未调度");
		} else {
			builder.append("\n调度状态：调度");
		}
		// 17 0：计价器未锁定；1：计价器锁定
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n计价器状态：未锁定");
		} else {
			builder.append("\n计价器状态：锁定");
		}
		// 18 出城留台标志0：正常；1：出城留台
		indexState = Integer.parseInt(String.valueOf(state.charAt(numState++)));
		if (indexState == 0) {
			builder.append("\n出城留台标志：正常");
		} else {
			builder.append("\n出城留台标志：出城留台");
		}
		// 19 0：OBD正常1：OBD故障对应故障码功能

		return builder.toString();
	}

	String[] alarmText = { "紧急报警", "预警", "卫星定位模块发生故障", "卫星定位天线未接或被剪断", "卫星定位天线短路", "ISU主电源欠压", "ISU主电源掉电", "液晶（LCD）显示ISU故障", "语音合成（TTS）模块故障", "摄像头故障", "计价器故障", "服务评价器故障（前后排）", "LED广告屏故障", "液晶（LCD）显示屏故障", "安全访问模块故障",
			"LED顶灯故障", "超速报警", "连续驾驶超时", "当天累计驾驶超时", "超时停车", "进出区域/路线", "路段行驶时间不足/过长", "禁行路段行驶", "车速传感器故障", "车辆非法点火", "车辆非法位移", "ISU存储异常", "录音设备故障", "计价器实时时钟超过规定误差范围" };
	String[] stateText = { "否", "是" };

	@Override
	public void setStatus(int index, boolean status) {
		// TODO Auto-generated method stub

	}

	@Override
	public void sendMsg(int type, Object obj) {
		// TODO Auto-generated method stub

	}
}
